<!DOCTYPE html>

<html class="no-js">

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <title></title>
  <meta name="description" content="" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />

  <script src="https://cdn.staticfile.org/axios/0.19.0-beta.1/axios.js"></script>

  <script src="../../cdn/vue/vue.global.min.js"></script>

  <link rel="stylesheet" href="../../cdn/element-plus/index.css" />
  <script src="../../cdn/element-plus/index.full.min.js"></script>
  <link rel="stylesheet" href="../../../lib/index.css" />
  <script src="../../../lib/avue.js"></script>
</head>

<body>
  <div id="app">
    <avue-tree :option="option" :data="data" v-model="form">
    </avue-tree>

  </div>
</body>
<script>
  var app = Vue.createApp({
    data() {
      return {
        form: {},
        data: [],
        option: {
          virtualize: true,
          formOption: {
            labelWidth: 100,
            column: [],
          }
        }
      }
    },
    mounted() {
      const getKey = (prefix, id) => {
        return `${prefix}-${id}`
      }
      const createData = (
        maxDeep,
        maxChildren,
        minNodesNumber,
        deep = 1,
        key = 'node'
      ) => {
        let id = 0
        return Array.from({ length: minNodesNumber })
          .fill(deep)
          .map(() => {
            const childrenNumber =
              deep === maxDeep ? 0 : Math.round(Math.random() * maxChildren)
            const nodeKey = getKey(key, ++id)
            return {
              id: nodeKey,
              label: nodeKey,
              children: childrenNumber
                ? createData(maxDeep, maxChildren, childrenNumber, deep + 1, nodeKey)
                : undefined,
            }
          })
      }
      this.data = createData(4, 30, 40)

    }
  })
  app.use(ElementPlus)
  app.use(AVUE)
  app.mount('#app')
</script>

</html>